#ifndef __EAGLESContext_H__
#define __EAGLESContext_H__

#include "U2GLESContext.h"

#ifdef __OBJC__
#   import <QuartzCore/CAEAGLLayer.h>
#endif

U2EG_NAMESPACE_BEGIN

class _U2GLESPrivate EAGLESContext : public U2GLESContext
{
	protected:
#ifdef __OBJC__
		CAEAGLLayer *mDrawable;
		EAGLContext *mContext;
#endif

	public:
#ifdef __OBJC__
		EAGLESContext(CAEAGLLayer *drawable, EAGLSharegroup *group);
		CAEAGLLayer * getDrawable() const;
		EAGLContext * getContext() const;
#endif
		virtual ~EAGLESContext();

		virtual void setCurrent();
		virtual void endCurrent();
		virtual U2GLESContext * clone() const;

		bool createFramebuffer();
		void destroyFramebuffer();

		/* The pixel dimensions of the backbuffer */
		GLint mBackingWidth;
		GLint mBackingHeight;

		/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
		GLuint mViewRenderbuffer;
		GLuint mViewFramebuffer;

		/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
		GLuint mDepthRenderbuffer;

		bool mIsMultiSampleSupported;
		GLsizei mNumSamples;
		GLuint mFSAAFramebuffer;
		GLuint mFSAARenderbuffer;
};

U2EG_NAMESPACE_END

#endif
